<%--
  Created by IntelliJ IDEA.
  User: 20964
  Date: 2020-05-26
  Time: 18:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
<%--    <script src="../js/jquery-3.4.1.min.js"></script>--%>
</head>
<body>
    <form class="layui-form" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label" style="color: red;font-size: 14px;margin-left: 16px;">分类名称(*)</label>
            <br>
            <input type="text" name="classificationName" placeholder="" autocomplete="off" class="layui-input"
                style="width: 91%;height: 27px;margin-left: 16px;margin-top: 8px;">
            <div style="margin-top: 8px;margin-right: 24px;float: right;">
                <button class="layui-btn" lay-submit lay-filter="addForm">保存</button>
                &nbsp;&nbsp;
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</body>
<script src="../../statics/js/common.js"></script>
<script src="../../statics/layui/layui.all.js"></script>
<script>

    var form = layui.form;
    var $ = layui.jquery;
    var layer = layui.layer;
    //监听提交
    form.on('submit(addForm)', function(data){
        console.log(data.field);

        // $.ajax({
        //     url : "/crm4/Classification/insert",
        //     data : data.field,
        //     // dataType : 'json',
        //     type : 'POST',
        //     error : function() {
        //         layer.msg("连接失败");
        //     }
        // });
        ajax("/crm4/Classification/insert",data.field, true, function(data){

            if(data.res == 1){
                layer.msg("修改成功");
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);//关闭当前页
            }else if(data.res == 2){
                layer.msg("修改失败");
            }

        });

    });

</script>
</html>
